import Vue from 'vue'
import store from '@/store'

function checkNeed() {
  return process.env.NODE_ENV !== 'production'
}

if (checkNeed()) {
  Vue.config.errorHandler = function(err, vm, info) {
    Vue.nextTick(() => {
      store.dispatch('errorLog/addErrorLog', {
        err,
        vm: vm.$vnode.tag,
        info,
        url: window.location.href
      })
    })
  }
}
